<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="申报时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="cyan"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          size="mini"
          @click="handleExport"
          v-hasPermi="['base:book:add']"
          >导出</el-button
        >
      </el-col></el-row
    >
    <el-table v-loading="loading" :data="buildingList">
      <el-table-column label="序号" align="center" type="index" />
      <el-table-column label="姓名" align="center" prop="driverName" />
      <el-table-column label="职业" align="center" prop="occupation" />
      <el-table-column label="工作单位" align="center" prop="company" />
      <el-table-column label="证件号" align="center" prop="licenseNo" />
      <el-table-column label="身份证号码" align="center" prop="idCard" width="180" />
      <el-table-column label="驾驶类型" align="center" prop="driveType" />
      <el-table-column
        label="申报时间"
        align="center"
        prop="createTime"
        width="180"
      >
        <!-- <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endDate, "{y}-{m}-{d}") }}</span>
        </template> -->
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {
  getDriverCheckinList,
  exportDriverCheckinList,
} from "@/api/checkin/driverCheckin";

export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 楼宇表格数据
      buildingList: [],
      dateRange: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      getDriverCheckinList(this.queryParams).then((response) => {
        const { list, total } = response.data;
        this.buildingList = list;
        this.total = total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 导出按钮操作 */
    handleExport() {
      // const queryParams = this.queryParams;
      // this.$confirm("是否确认导出所有楼宇数据项?", "警告", {
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   type: "warning",
      // })
      //   .then(function () {
      //     return exportBuilding(queryParams);
      //   })
      //   .then((response) => {
      //     this.download(response.msg);
      //   });
      exportDriverCheckinList().then((res) => {
        this.download(res.msg);
      });
    },
  },
};
</script>
